﻿using Platformer_Example.Content.Images.Environment;
using Platformer_Example.Controller.Input;
using Platformer_Example.Screen.Common;
using Transformable_Engine_v2.Engine;
using Transformable_Engine_v2.Engine.Animation.ColorAnimation;
using Transformable_Engine_v2.Engine.Animation.PositionAnimation;
using Transformable_Engine_v2.Engine.Animation.Trajectory;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.Graphics;
using Transformable_Engine_v2.Engine.Input;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Platformer_Example.Screen.MainMenu
{
    public class MainMenu : BaseScreen
    {
        public override void LoadContent()
        {
            SpritesheetMenu.LoadContent();
            SpritesheetDefaultFont.LoadContent();

            Container titleContainer = new Container(Game.Options.ScreenSize.X/2, 7);
            ImageContainer titleProject = new ImageContainer
                                              {
                                                  PositionGridBound = new TE_Vector2(-Game.Options.ScreenSize.X, 0),
                                                  Sprite = SpritesheetMenu.GetSprite(SpritesheetMenu.Title.Project),
                                                  Origin = TE_Rectangle.Alignment.TopMiddle,
                                              };
            ImageContainer titleMaverick = new ImageContainer
                                               {
                                                   PositionGridBound = new TE_Vector2(-Game.Options.ScreenSize.X, 10),
                                                   Sprite = SpritesheetMenu.GetSprite(SpritesheetMenu.Title.Maverick),
                                                   Origin = TE_Rectangle.Alignment.TopMiddle
                                               };
            titleProject.AddAnimations(new PositionAnimation(new OvershootEasing(BaseTrajectory.Easing.EaseOut), new TE_Vector2(0, 0), 1250, false, 200));
            titleMaverick.AddAnimations(new PositionAnimation(new OvershootEasing(BaseTrajectory.Easing.EaseOut), new TE_Vector2(0, 10), 1250, false, 200 + 250));

            titleContainer.AddChildren(titleProject, titleMaverick);
            AddChildren(titleContainer);

            CallMethod(2000, ClickAnywhereToStart);

            base.LoadContent();
        }

        void ClickAnywhereToStart()
        {
            var pressAny = new ImageContainer
                               {
                                   PositionGridBound =
                                       new TE_Vector2(Game.Options.ScreenSize.X/2, 27 + (Game.Options.ScreenSize.Y - 27) / 2),
                                   Sprite = SpritesheetMenu.GetSprite(SpritesheetMenu.Title.PressAny),
                                   Color = Color.Transparent,
                                   Origin = TE_Rectangle.Alignment.CenterMiddle
                               };
            pressAny.AddAnimations(new ColorAnimation(new SinusTrajectory(), Color.White, 1000, true));
            AddChildren(pressAny);
        }

        public override void Keypressed(InputState.Key key)
        {
            //Change to OptionsSelection screen
        }

        public override void KeyReleased(InputState.Key key)
        {
            
        }

        public override void InvalidKeyPressed(KeyboardInput.Key keyCode)
        {
            //Change to Keybindings screen
        }
    }
}